package com.example.arch.room;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.Query;
import com.example.arch.bean.User;
import io.reactivex.Flowable;

import java.util.List;

/**
 * Created by zhangwei on 2017/6/27.
 */
@Dao
public interface UserDao {

    @Query("SELECT * FROM user")
    List<User> getAll();

    @Query("SELECT * FROM user")
    Flowable<List<User>> loadAll();

    @Query("SELECT * from user where uid = :id LIMIT 1")
    public Flowable<User> loadUserById(int id);

    @Query("SELECT * FROM user WHERE name LIKE :first LIMIT 1")
    User findByName(String first);

    @Insert
    void insertAll(User... users);

    @Delete
    void delete(User user);
}
